lukeonline

source for my website
git clone https://git.lukeonline.net/repos/lukeonline
Log | Files | Refs | README | LICENSE

[id].astro (1065B)


      1 ---
      2 import Base from '../../layouts/Base.astro'
      3 import Table from '../../components/Table.astro'
      4 
      5 import { getCollection, render } from 'astro:content'
      6 
      7 export async function getStaticPaths() {
      8   const photos = await getCollection('photos')
      9 
     10   return photos[0].data.map((photo) => ({
     11     params: {
     12       id: photo.id.toString(),
     13     },
     14     props: {
     15       photo,
     16     },
     17   }))
     18 }
     19 
     20 const { photo } = Astro.props
     21 
     22 const photoSourceUrl = '/photos/source/'
     23 const photoExtension = '.jpg'
     24 
     25 let coordString = 'None'
     26 
     27 if (photo.coordinates) {
     28   coordString = `${photo.coordinates.x}, ${photo.coordinates.y}`
     29 }
     30 
     31 const photoPath = `${photoSourceUrl}${photo.id}${photoExtension}`
     32 
     33 const tableData = {
     34   Location: photo.location,
     35   Coordinates: coordString,
     36   Tags: photo.tags,
     37 }
     38 ---
     39 
     40 <Base title={photo.date}>
     41   <div class="flex flex-col gap-4">
     42     <a href={photoPath}>
     43       <img src={photoPath} alt={photo.desc} />
     44     </a>
     45     <div class="flex flex-col gap-1">
     46       <span>{photo.desc}</span>
     47     </div>
     48     <div>
     49       <Table rows={tableData} />
     50     </div>
     51   </div>
     52 </Base>